Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(types): support ns timestamp #19827

Merged
merged 16 commits into from
Dec 30, 2024
Merged

feat(types): support ns timestamp #19827

merged 16 commits into from
Dec 30, 2024

Conversation

xxhZs
Copy link
Contributor

@xxhZs xxhZs commented Dec 17, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

our timestamp only support ms, But our internal implementation is capable of ns, it's just that we automatically convert it to ms when we read it in, and this pr can read ns to support ns.

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.
  • I have added test labels as necessary.
  • I have added fuzzing tests or opened an issue to track them.
  • My PR contains breaking changes.
  • My PR changes performance-critical code, so I will run (micro) benchmarks and present the results.
  • My PR contains critical fixes that are necessary to be merged into the latest release.

Documentation

  • My PR needs documentation updates.
Release note

@xxhZs xxhZs requested a review from a team as a code owner December 17, 2024 08:37
@xxhZs xxhZs requested a review from xxchan December 17, 2024 08:37
@graphite-app graphite-app bot requested a review from a team December 17, 2024 09:25
@hzxa21 hzxa21 requested a review from wcy-fdu December 18, 2024 03:40
@wcy-fdu
Copy link
Contributor

wcy-fdu commented Dec 18, 2024

I tested whether I could read nanosecond in the parquet file on this branch, and it seemed to work.
image

@wcy-fdu wcy-fdu enabled auto-merge December 19, 2024 04:39
@wcy-fdu wcy-fdu disabled auto-merge December 19, 2024 04:40
@wcy-fdu
Copy link
Contributor

wcy-fdu commented Dec 19, 2024

sorry, mis clicked update branch

@wcy-fdu
Copy link
Contributor

wcy-fdu commented Dec 19, 2024

cc @xiangjinwu PTAL❤️

Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Could you also include the testing SQLs you have tried?
  • Is any caller of to_protobuf/from_protobuf assuming that Timestamp would be fixed 64-bit? This assumption is no longer true.

)
}
let dt = s
.parse::<jiff::civil::DateTime>()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to introduce yet another dependency in addition to chrono and speedate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because chrono can't be parsed, and speedate is only parsed at the us level

src/common/src/types/datetime.rs Outdated Show resolved Hide resolved
src/common/src/types/datetime.rs Outdated Show resolved Hide resolved
@xxhZs
Copy link
Contributor Author

xxhZs commented Dec 23, 2024

  • Could you also include the testing SQLs you have tried?

added in ci

@xxhZs xxhZs requested a review from xiangjinwu December 23, 2024 07:35
@xiangjinwu
Copy link
Contributor

Btw you can fix the e2e test with rowsort.

https://www.sqlite.org/sqllogictest/doc/trunk/about.wiki

The default is "nosort". In nosort mode, the results appear in exactly the order in which they were received from the database engine. The nosort mode should only be used on queries that have an ORDER BY clause or which only have a single row of result, since otherwise the order of results is undefined and might vary from one database engine to another. The "rowsort" mode gathers all output from the database engine then sorts it by rows on the client side.

#6776

If there's rowsort, slt file will contain sorted results.

@xxhZs xxhZs force-pushed the xxh/support-timestamp-ns-1 branch from 26d9664 to 6b8af32 Compare December 26, 2024 07:49
@xiangjinwu
Copy link
Contributor

xiangjinwu commented Dec 26, 2024

FYI regarding your latest e2e failure, it is actually a bug in our existing to_char implementation #19944:

1 BC in PostgreSQL is year 0 in chrono. Although chrono also provides DateLike::year_ce method, its strftime module does not provide a specifier to use year_ce instead of year.

Given it is out of scope of this PR, let's just replace the case with one without BC.

fxi ci

fix ci

fix ci
@xxhZs xxhZs force-pushed the xxh/support-timestamp-ns-1 branch from 6b8af32 to 2c87c76 Compare December 26, 2024 09:54
Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good to me. Just more to test:

  • distinct / group by / order by / max
  • extract with epoch / second / milliseconds / microseconds
  • make_timestamp

}
let dt = s
.parse::<jiff::civil::DateTime>()
.map_err(|_| ErrorKind::ParseTimestamp)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message of ParseTimestamp shall be updated from up to 6 digits to up to 9 digits.

@wcy-fdu
Copy link
Contributor

wcy-fdu commented Dec 27, 2024

Thanks for the efforts. I will doing some testing on sink side later.

@xiangjinwu
Copy link
Contributor

  • Is any caller of to_protobuf/from_protobuf assuming that Timestamp would be fixed 64-bit? This assumption is no longer true.

Answering my own question: there is but it is only used as a hint - so okay to be inaccurate.

to_protobuf is used here. The size_of::<T> may result in an inaccurate estimate for buffer capacity.

let mut output_buffer = Vec::<u8>::with_capacity(self.len() * size_of::<T>());
for v in self.iter() {
v.map(|node| node.to_protobuf(&mut output_buffer));
}

from_protobuf is used here. Movement of Cursor makes no assumption on item sizes.

for not_null in bitmap.iter() {
if not_null {
let v = T::from_protobuf(&mut cursor)?;
builder.append(Some(v));
} else {
builder.append(None);
}
}

@xxhZs xxhZs enabled auto-merge December 30, 2024 05:22
@xxhZs xxhZs force-pushed the xxh/support-timestamp-ns-1 branch from 2a866bb to a3cb6da Compare December 30, 2024 05:23
@xxhZs xxhZs force-pushed the xxh/support-timestamp-ns-1 branch 3 times, most recently from 72a5ad9 to 12fb1f0 Compare December 30, 2024 08:09
fix ci

fix ci

fx i

fix ci

fix ci

fix ci

fxi ci

fix ci

fix ci

fix ci

fix ci
@xxhZs xxhZs force-pushed the xxh/support-timestamp-ns-1 branch from 8a5496d to 758cda7 Compare December 30, 2024 08:25
@xxhZs xxhZs added this pull request to the merge queue Dec 30, 2024
Merged via the queue into main with commit b8c9c23 Dec 30, 2024
28 of 29 checks passed
@xxhZs xxhZs deleted the xxh/support-timestamp-ns-1 branch December 30, 2024 10:35
github-actions bot pushed a commit that referenced this pull request Dec 30, 2024
github-merge-queue bot pushed a commit that referenced this pull request Dec 31, 2024
github-actions bot pushed a commit that referenced this pull request Jan 2, 2025
@pjpringle
Copy link

Nice useful feature for trading use cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants